home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / tex / dvivga9.zip / DVIFILE.H < prev    next >
Text File  |  1988-06-11  |  5KB  |  164 lines

  1. /* -*-C-*- dvifile.h */
  2. /*-->dvifile*/
  3. /**********************************************************************/
  4. /****************************** dvifile *******************************/
  5. /**********************************************************************/
  6.  
  7. void
  8. dvifile(argc,argv,filestr)
  9. int   argc;            /* argument count */
  10. char* argv[];            /* argument strings */
  11. char* filestr;            /* DVI filename to process */
  12. {
  13.  
  14. #define PAGENUMBER(p) ((p) < 0 ? (page_count + 1 + (p)) : (p))
  15.  
  16.     register INT16 i,j,m;    /* loop indices */
  17.     register INT16 swap;    /* swap storage */
  18.  
  19.     INT16 m_begin,m_end,m_step;    /* loop limits and increment */
  20.     INT16 list[3];        /* index list for sort */
  21.     char tempstr[MAXSTR];    /* temporary string storage */
  22.  
  23.  
  24.     /*
  25.     Establish the default  font file  search order.  This  is done  here
  26.     instead of  in  initglob()  or  option(),  because  both  could  set
  27.     fontlist[].
  28.  
  29.     By default, the search list contains  names for the PK, GF, and  PXL
  30.     font  files;  that  order   corresponds  to  increasing  size   (and
  31.     therefore, presumably, increasing  processing cost)  of font  raster
  32.     information.  This search  order may  be overridden at  run time  by
  33.     defining an alternate one in the environment variable FONTLIST;  the
  34.     order of  the  strings  "PK",  "GF",  and  "PXL"  in  that  variable
  35.     determines the search  order, and  letter case  is NOT  significant.
  36.     The  substrings  may  be  separated   by  zero  or  more   arbitrary
  37.     characters, so  the  values  "PK-GF-PXL", "PK  GF  PXL",  "PKGFPXL",
  38.     "PK;GF;PXL", "PK/GF/PXL"  are all  acceptable,  and all  choose  the
  39.     default search  order.   This  flexibility  in  separator  character
  40.     choice is occasioned  by the  requirement on some  systems that  the
  41.     environment variable have the syntax of a file name, or be a  single
  42.     "word".  If  any  substring  is  omitted, then  that  font  will  be
  43.     excluded from consideration.  Thus, "GF" permits the use only of  GF
  44.     font files.
  45.  
  46.     The indexes gf_index, pk_index, and pxl_index are in -1 .. 2, and at
  47.     least one must be non-negative.  A negative index excludes that font
  48.     file type from the search.
  49.     */
  50.  
  51.     /* Note that non-negative entries in list[] are UNIQUE. */
  52.     list[0] = gf_index = (INT16)strid2(fontlist,"GF");
  53.     list[1] = pk_index = (INT16)strid2(fontlist,"PK");
  54.     list[2] = pxl_index = (INT16)strid2(fontlist,"PXL");
  55.  
  56.     for (i = 0; i < 3; ++i)    /* put list in non-decreasing order */
  57.     for (j = i+1; j < 3; ++j)
  58.         if (list[i] > list[j])
  59.         {
  60.         swap = list[i];
  61.         list[i] = list[j];
  62.         list[j] = swap;
  63.         }
  64.     for (i = 0; i < 3; ++i)    /* assign indexes 0,1,2 */
  65.     if (list[i] >= 0)
  66.     {
  67.             if (list[i] == gf_index)
  68.         gf_index = i;
  69.             else if (list[i] == pk_index)
  70.         pk_index = i;
  71.             else if (list[i] == pxl_index)
  72.         pxl_index = i;
  73.     }
  74.  
  75.     if ((gf_index < 0) && (pk_index < 0) && (pxl_index < 0))
  76.     (void)fatal("dvifile():  FONTLIST does not define at least one of \
  77. GF, PK, or PXL fonts");
  78.  
  79.     (void)dviinit(filestr);    /* initialize DVI file processing */
  80.  
  81.     (void)devinit(argc,argv);    /* initialize device output */
  82.  
  83.     (void)readpost();
  84.     (void)FSEEK(dvifp, 14L, 0); /* position past preamble */
  85.     (void)getbytes(dvifp, tempstr,
  86.     (BYTE)nosignex(dvifp,(BYTE)1)); /* flush DVI comment */
  87.  
  88.     cur_page_number = 0;
  89.  
  90. #if VGASCREEN
  91.     vgasequence();
  92.  
  93. #else
  94. #if ((HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2) & !HPJETII)
  95.     /* print pages in reverse order because of laser printer */
  96.     /* page stacking */
  97.     if (backwards)
  98.     {
  99.     m_begin = 1;
  100.     m_end = page_count;
  101.     m_step = 1;
  102.     }
  103.     else    /* normal device order */
  104.     {
  105.     m_begin = page_count;
  106.     m_end = 1;
  107.     m_step = -1;
  108.     }
  109.  
  110. #else
  111.   /* NOT (HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2) */
  112.     /* print pages in forward order for most devices */
  113.     if (backwards)
  114.     {
  115.     m_begin = page_count;
  116.     m_end = 1;
  117.     m_step = -1;
  118.     }
  119.     else
  120.     {
  121.     m_begin = 1;
  122.     m_end = page_count;
  123.     m_step = 1;
  124.     }
  125. #endif /* (HPLASERJET|HPJETPLUS|GOLDENDAWNGL100|POSTSCRIPT|IMPRESS|CANON_A2) */
  126.  
  127.     for (i = 0; i < npage; ++i)        /* make page numbers positive */
  128.     {                    /* and order pairs non-decreasing */
  129.     page_begin[i] = PAGENUMBER(page_begin[i]);
  130.     page_end[i] = PAGENUMBER(page_end[i]);
  131.     if (page_begin[i] > page_end[i])
  132.     {
  133.         swap = page_begin[i];
  134.         page_begin[i] = page_end[i];
  135.         page_end[i] = swap;
  136.     }
  137.     }
  138.  
  139.     for (m = m_begin; ; m += m_step)
  140.     {
  141.     for (i = 0; i < npage; ++i)    /* search page list */
  142.         if ( IN(page_begin[i],m,page_end[i]) &&
  143.             (((m - page_begin[i]) % page_step[i]) == 0) )
  144.         {
  145.         if (!quiet)        /* start progress report */
  146.             (void)fprintf(stderr,"[%d", m);
  147.         cur_page_number++;/* sequential page number 1..N */
  148.         cur_index = m-1;    /* remember index globally */
  149.             prtpage(page_ptr[cur_index]);
  150.         if (!quiet)        /* finish progress report */
  151.             (void)fprintf(stderr,"] ");
  152.         break;
  153.         }
  154.     if (m == m_end)            /* exit loop after last page */
  155.         break;
  156.     }
  157.  
  158. #endif /* VGASCREEN */
  159.  
  160.     (void)devterm();        /* terminate device output */
  161.  
  162.     (void)dviterm();        /* terminate DVI file processing */
  163. }
  164.